package com.vanke.devops.api.config;

import com.vanke.devops.domain.properties.InfluxDbProperties;
import org.influxdb.InfluxDB;
import org.influxdb.InfluxDBFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author 陈景阳
 * @since 2018/6/9
 */
@Configuration
@EnableConfigurationProperties(InfluxDbProperties.class)
public class InfluxDbConfig {

    @Autowired
    private InfluxDbProperties influxDbProperties;

    @Bean
    public InfluxDB getInfluxDB(){
        InfluxDB influxDB = InfluxDBFactory.connect(influxDbProperties.getHost());
        influxDB.setDatabase(influxDbProperties.getDatabase());
        return influxDB;
    }
}
